---------------------------------------------------------------------------------
       log:  C:\papers\formateur\changepmc.log
  log type:  text
 opened on:  13 Nov 2010, 03:34:36

. #delimit ;
delimiter now ;
. set mem 30m;
(30720k)

. /*clear matrix;*/
> /*clear mata; */
> 
> set more off;

. *     ***************************************************************** *;
. *     ***************************************************************** *;
. *       File-Name:  stata_mxl_predictprob.do                            *;
. *       Date:       November 9, 2010                                    *;
. *       Author:     GG/MG                                               *;
. *       Purpose:    Produce Tables 1 and 2 in AJPS paper                *;
. *       Input File:     europe.dta                                      *;
. *       Output File:    stata_mxl_predictprob.log                       *;
. *       Data Output:    none                                            *;
. *       Previous file:  europe.dta                                      *;
. *       Machine:        Matt's desktop                                  *;
. *     ****************************************************************  *;
. *     ****************************************************************  *;
. use "europe.dta", clear;

. *     ****************************************************************  *;
. *       Model 6: Western Europe                                         *;
. *     ****************************************************************  *;
. mixlogit choice largestparty_east party_seatshare_east medianparty1_east pres
> identparty_east previousPM_east previousPM_conflict_east previousPM_gain1_eas
> t previous_cabinet_gain1_east,  
>     rand (largestparty party_seatshare medianparty1 presidentparty previousPM
>  president_investiture president_direct previousPM_conflict previousPM_gain1 
> previous_cabinet_gain1) 
>     ln(0) nrep(125) group(cabinetcode);

Iteration 0:   log likelihood = -255.29786  (not concave)
Iteration 1:   log likelihood = -245.38797  (not concave)
Iteration 2:   log likelihood =  -228.8695  
Iteration 3:   log likelihood = -221.24204  (not concave)
Iteration 4:   log likelihood = -221.16184  (not concave)
Iteration 5:   log likelihood = -220.39987  
Iteration 6:   log likelihood = -219.61402  
Iteration 7:   log likelihood = -219.46931  
Iteration 8:   log likelihood = -219.42816  (not concave)
Iteration 9:   log likelihood = -219.41127  (not concave)
Iteration 10:  log likelihood = -219.40734  (not concave)
Iteration 11:  log likelihood = -219.38014  
Iteration 12:  log likelihood = -219.35916  
Iteration 13:  log likelihood = -219.35268  
Iteration 14:  log likelihood = -219.35266  

Mixed logit model                                 Number of obs   =       2039
                                                  LR chi2(10)     =      19.54
Log likelihood = -219.35266                       Prob > chi2     =     0.0339

------------------------------------------------------------------------------
      choice |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
Mean         |
largestp~ast |  -1.253544   2.017873    -0.62   0.534    -5.208503    2.701414
party_se~ast |   .2877481   .1444587     1.99   0.046     .0046143    .5708819
medianpa~ast |  -3.117227   1.721757    -1.81   0.070    -6.491809    .2573546
presi~y_east |  -.4970681   1.853252    -0.27   0.789    -4.129376     3.13524
previ~M_east |   -2.19965   2.606521    -0.84   0.399    -7.308337    2.909037
previ~t_east |   1.126725   3.208478     0.35   0.725    -5.161776    7.415226
previousPM.. |  -.0930831   .4810077    -0.19   0.847    -1.035841    .8496747
previous_c.. |   .0517841   .1988117     0.26   0.795    -.3378797    .4414479
largestparty |   2.109019   1.104417     1.91   0.056    -.0555996    4.273637
party_seat~e |   .1351541   .0258657     5.23   0.000     .0844583    .1858499
medianparty1 |   1.392319   .3828235     3.64   0.000     .6419985    2.142639
presidentp~y |   5.250695   2.428888     2.16   0.031      .490162    10.01123
  previousPM |   2.841572   1.038968     2.73   0.006     .8052325    4.877912
president_~e |  -3.060496   2.130412    -1.44   0.151    -7.236027    1.115035
president~ct |  -3.915977     2.1442    -1.83   0.068    -8.118531    .2865775
previousP~ct |  -2.618633   1.261868    -2.08   0.038    -5.091848   -.1454174
previousPM~1 |   .4958572   .2007184     2.47   0.013     .1024564     .889258
previous_c~1 |   .0367127   .0403208     0.91   0.363    -.0423147    .1157401
-------------+----------------------------------------------------------------
SD           |
largestparty |   -4.72622   1.779758    -2.66   0.008    -8.214482   -1.237957
party_seat~e |  -.0074871   .0352742    -0.21   0.832    -.0766233    .0616491
medianparty1 |    .137813   .9798871     0.14   0.888     -1.78273    2.058357
presidentp~y |   -.266903   1.275177    -0.21   0.834    -2.766204    2.232398
  previousPM |   -1.90488   1.048407    -1.82   0.069     -3.95972    .1499603
president_~e |  -.4246113   1.592647    -0.27   0.790    -3.546143     2.69692
president~ct |    .591708    1.45034     0.41   0.683    -2.250906    3.434321
previousP~ct |  -.1339581   2.773063    -0.05   0.961    -5.569061    5.301145
previousPM~1 |     .11201   .2052589     0.55   0.585      -.29029      .51431
previous_c~1 |   .1484155   .0862285     1.72   0.085    -.0205892    .3174201
------------------------------------------------------------------------------

.     *     ****************************************************************  *
> ;
. *       Now produce Figure 1                                            *;
. *     ****************************************************************  *;
. matrix coeffs = e(b);

. matrix covmat = e(V);

. keep if cabinetcode==1222;
(2400 observations deleted)

. set obs 10000;
obs was 12, now 10000

. generate pvda = 0;

. replace pvda = 1 if partyID==7;
(1 real change made)

. generate cda = 0;

. replace cda = 1 if partyID==13;
(1 real change made)

. generate vvd = 0;

. replace vvd = 1 if partyID==22;
(1 real change made)

. generate d66 = 0;

. replace d66 = 1 if partyID==10;
(1 real change made)

. replace previousPM_conflict = 1 if cda==1;
(1 real change made)

. generate ppvda1 = .;
(10000 missing values generated)

. generate pcda1 = .;
(10000 missing values generated)

. generate pvvd1 = .;
(10000 missing values generated)

. generate pd661 = .;
(10000 missing values generated)

. generate ppvda2 = .;
(10000 missing values generated)

. generate pcda2 = .;
(10000 missing values generated)

. generate pvvd2 = .;
(10000 missing values generated)

. generate pd662 = .;
(10000 missing values generated)

. generate ppvda3 = .;
(10000 missing values generated)

. generate pcda3 = .;
(10000 missing values generated)

. generate pvvd3 = .;
(10000 missing values generated)

. generate pd663 = .;
(10000 missing values generated)

. generate ppvda4 = .;
(10000 missing values generated)

. generate pcda4 = .;
(10000 missing values generated)

. generate pvvd4 = .;
(10000 missing values generated)

. generate pd664 = .;
(10000 missing values generated)

. drawnorm b1-b28, means(coeffs) cov(covmat) double;

.  nois _dots 0, title(largest party sim) reps(10000);
largest party sim (10000)
----+--- 1 ---+--- 2 ---+--- 3 ---+--- 4 ---+--- 5 

. forvalues j = 1/10000 {;
  2.   mkmat b1-b28 if _n==`j', matrix(bdraw);
  3.   mixlpred2 pprobs;
  4.    qui generate pt1 = pprobs * pvda;
  5.   qui generate ct1 = pprobs * cda;
  6.   qui generate vt1 = pprobs * vvd;
  7.   qui generate dt1 = pprobs * d66;
  8.   qui replace previousPM = 1 if pvda==1;
  9.   qui replace previousPM_gain1 = -13.33333 if pvda==1;
 10.   qui replace previous_cabinet_gain1 = -7.333344 if pvda==1;
 11.   qui replace previousPM_conflict = 1 if pvda==1;
 12.   qui replace previousPM = 0 if cda==1;
 13.   qui replace previousPM_gain1 = 0 if cda==1;
 14.   qui replace previous_cabinet_gain1 = 0 if cda==1;
 15.   qui replace previousPM_conflict = 0 if cda==1;
 16. mixlpred2 pprobs2;
 17.   qui generate pt2 = pprobs2 * pvda;
 18.   qui generate ct2 = pprobs2 * cda;
 19.   qui generate vt2 = pprobs2 * vvd;
 20.   qui generate dt2 = pprobs2 * d66;
 21.   qui replace previousPM = 1 if vvd==1;
 22.   qui replace previousPM_gain1 = -13.33333 if vvd==1;
 23.   qui replace previous_cabinet_gain1 = -7.333344 if vvd==1;
 24.   qui replace previousPM_conflict = 1 if vvd==1;
 25.   qui replace previousPM = 0 if pvda==1;
 26.   qui replace previousPM_gain1 = 0 if pvda==1;
 27.   qui replace previous_cabinet_gain1 = 0 if pvda==1;
 28.   qui replace previousPM_conflict = 0 if pvda==1;
 29. mixlpred2 pprobs3;
 30.   qui generate pt3 = pprobs3 * pvda;
 31.   qui generate ct3 = pprobs3 * cda;
 32.   qui generate vt3 = pprobs3 * vvd;
 33.   qui generate dt3 = pprobs3 * d66;
 34.   qui replace previousPM = 1 if d66==1;
 35.   qui replace previousPM_gain1 = -13.33333 if d66==1;
 36.   qui replace previous_cabinet_gain1 = -7.333344 if d66==1;
 37.   qui replace previousPM_conflict = 1 if d66==1;
 38.   qui replace previousPM = 0 if vvd==1;
 39.   qui replace previousPM_gain1 = 0 if vvd==1;
 40.   qui replace previous_cabinet_gain1 = 0 if vvd==1;
 41.   qui replace previousPM_conflict = 0 if vvd==1;
 42. mixlpred2 pprobs4;
 43.   qui generate pt4 = pprobs4 * pvda;
 44.   qui generate ct4 = pprobs4 * cda;
 45.   qui generate vt4 = pprobs4 * vvd;
 46.   qui generate dt4 = pprobs4 * d66;
 47.   qui replace previousPM = 1 if cda==1;
 48.   qui replace previousPM_gain1 = -13.33333 if cda==1;
 49.   qui replace previous_cabinet_gain1 = -7.333344 if cda==1;
 50.   qui replace previousPM_conflict = 1 if cda==1;
 51.   qui replace previousPM = 0 if d66==1;
 52.   qui replace previousPM_gain1 = 0 if d66==1;
 53.   qui replace previous_cabinet_gain1 = 0 if d66==1;
 54.   qui replace previousPM_conflict = 0 if d66==1;
 55.   egen pt1s = sum(pt1);
 56.   egen ct1s = sum(ct1);
 57.   egen vt1s = sum(vt1);
 58.   egen dt1s = sum(dt1);
 59.   egen pt2s = sum(pt2);
 60.   egen ct2s = sum(ct2);
 61.   egen vt2s = sum(vt2);
 62.   egen dt2s = sum(dt2);
 63.   egen pt3s = sum(pt3);
 64.   egen ct3s = sum(ct3);
 65.   egen vt3s = sum(vt3);
 66.   egen dt3s = sum(dt3);
 67.   egen pt4s = sum(pt4);
 68.   egen ct4s = sum(ct4);
 69.   egen vt4s = sum(vt4);
 70.   egen dt4s = sum(dt4);
 71.   qui replace ppvda1 = pt1s if _n==`j';
 72.   qui replace pcda1 = ct1s if _n==`j';
 73.   qui replace pvvd1 = vt1s if _n==`j';
 74.   qui replace pd661 = dt1s if _n==`j';
 75.   qui replace ppvda2 = pt2s if _n==`j';
 76.   qui replace pcda2 = ct2s if _n==`j';
 77.   qui replace pvvd2 = vt2s if _n==`j';
 78.   qui replace pd662 = dt2s if _n==`j';
 79.   qui replace ppvda3 = pt3s if _n==`j';
 80.   qui replace pcda3 = ct3s if _n==`j';
 81.   qui replace pvvd3 = vt3s if _n==`j';
 82.   qui replace pd663 = dt3s if _n==`j';
 83.   qui replace ppvda4 = pt4s if _n==`j';
 84.   qui replace pcda4 = ct4s if _n==`j';
 85.   qui replace pvvd4 = vt4s if _n==`j';
 86.   qui replace pd664 = dt4s if _n==`j';
 87. drop pt1 ct1 vt1 dt1 pt2 ct2 vt2 dt2 pt3 ct3 vt3 dt3 pt4 ct4 vt4 dt4 
> pt1s ct1s vt1s dt1s pt2s ct2s vt2s dt2s pt3s ct3s vt3s dt3s pt4s ct4s vt4s dt
> 4s 
> pprobs pprobs2 pprobs3 pprobs4;
 88.  nois _dots `j' 0;
 89.   };
..................................................    50
..................................................   100
..................................................   150
..................................................   200
..................................................   250
..................................................   300
..................................................   350
..................................................   400
..................................................   450
..................................................   500
..................................................   550
..................................................   600
..................................................   650
..................................................   700
..................................................   750
..................................................   800
..................................................   850
..................................................   900
..................................................   950
..................................................  1000
..................................................  1050
..................................................  1100
..................................................  1150
..................................................  1200
..................................................  1250
..................................................  1300
..................................................  1350
..................................................  1400
..................................................  1450
..................................................  1500
..................................................  1550
..................................................  1600
..................................................  1650
..................................................  1700
..................................................  1750
..................................................  1800
..................................................  1850
..................................................  1900
..................................................  1950
..................................................  2000
..................................................  2050
..................................................  2100
..................................................  2150
..................................................  2200
..................................................  2250
..................................................  2300
..................................................  2350
..................................................  2400
..................................................  2450
..................................................  2500
..................................................  2550
..................................................  2600
..................................................  2650
..................................................  2700
..................................................  2750
..................................................  2800
..................................................  2850
..................................................  2900
..................................................  2950
..................................................  3000
..................................................  3050
..................................................  3100
..................................................  3150
..................................................  3200
..................................................  3250
..................................................  3300
..................................................  3350
..................................................  3400
..................................................  3450
..................................................  3500
..................................................  3550
..................................................  3600
..................................................  3650
..................................................  3700
..................................................  3750
..................................................  3800
..................................................  3850
..................................................  3900
..................................................  3950
..................................................  4000
..................................................  4050
..................................................  4100
..................................................  4150
..................................................  4200
..................................................  4250
..................................................  4300
..................................................  4350
..................................................  4400
..................................................  4450
..................................................  4500
..................................................  4550
..................................................  4600
..................................................  4650
..................................................  4700
..................................................  4750
..................................................  4800
..................................................  4850
..................................................  4900
..................................................  4950
..................................................  5000
..................................................  5050
..................................................  5100
..................................................  5150
..................................................  5200
..................................................  5250
..................................................  5300
..................................................  5350
..................................................  5400
..................................................  5450
..................................................  5500
..................................................  5550
..................................................  5600
..................................................  5650
..................................................  5700
..................................................  5750
..................................................  5800
..................................................  5850
..................................................  5900
..................................................  5950
..................................................  6000
..................................................  6050
..................................................  6100
..................................................  6150
..................................................  6200
..................................................  6250
..................................................  6300
..................................................  6350
..................................................  6400
..................................................  6450
..................................................  6500
..................................................  6550
..................................................  6600
..................................................  6650
..................................................  6700
..................................................  6750
..................................................  6800
..................................................  6850
..................................................  6900
..................................................  6950
..................................................  7000
..................................................  7050
..................................................  7100
..................................................  7150
..................................................  7200
..................................................  7250
..................................................  7300
..................................................  7350
..................................................  7400
..................................................  7450
..................................................  7500
..................................................  7550
..................................................  7600
..................................................  7650
..................................................  7700
..................................................  7750
..................................................  7800
..................................................  7850
..................................................  7900
..................................................  7950
..................................................  8000
..................................................  8050
..................................................  8100
..................................................  8150
..................................................  8200
..................................................  8250
..................................................  8300
..................................................  8350
..................................................  8400
..................................................  8450
..................................................  8500
..................................................  8550
..................................................  8600
..................................................  8650
..................................................  8700
..................................................  8750
..................................................  8800
..................................................  8850
..................................................  8900
..................................................  8950
..................................................  9000
..................................................  9050
..................................................  9100
..................................................  9150
..................................................  9200
..................................................  9250
..................................................  9300
..................................................  9350
..................................................  9400
..................................................  9450
..................................................  9500
..................................................  9550
..................................................  9600
..................................................  9650
..................................................  9700
..................................................  9750
..................................................  9800
..................................................  9850
..................................................  9900
..................................................  9950
.................................................. 10000

. generate pvdad2 = ppvda2 - ppvda1;

. generate pvdad3 = ppvda3 - ppvda1;

. generate pvdad4 = ppvda4 - ppvda1;

. generate cdad2 = pcda2 - pcda1;

. generate cdad3 = pcda3 - pcda1;

. generate cdad4 = pcda4 - pcda1;

. generate vvdd2 = pvvd2 - pvvd1;

. generate vvdd3 = pvvd3 - pvvd1;

. generate vvdd4 = pvvd4 - pvvd1;

. generate d66d2 = pd662 - pd661;

. generate d66d3 = pd663 - pd661;

. generate d66d4 = pd664 - pd661;

. summarize 
> ppvda1 pcda1 pvvd1 pd661
> ppvda2 pcda2 pvvd2 pd662
> ppvda3 pcda3 pvvd3 pd663
> ppvda4 pcda4 pvvd4 pd664
> pvdad2 cdad2 vvdd2 d66d2
> pvdad3 cdad3 vvdd3 d66d3
> pvdad4 cdad4 vvdd4 d66d4;

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
      ppvda1 |     10000    .5937447    .1022223   .0100786   .7782838
       pcda1 |     10000    .0975309    .0947965   .0000124   .8954982
       pvvd1 |     10000    .1362104    .0323751   .0265797   .3329838
       pd661 |     10000    .0707475    .0140013   .0168686   .1756394
      ppvda2 |     10000    .2186625     .093676   .0009962   .6425075
-------------+--------------------------------------------------------
       pcda2 |     10000     .521726    .1013012   .1464301   .8707237
       pvvd2 |     10000     .109346    .0281737   .0334781   .2312351
       pd662 |     10000    .0586106    .0153411   .0163615   .1262343
      ppvda3 |     10000    .5269238     .105523   .0139583    .730431
       pcda3 |     10000    .3294141    .0751605    .111424   .8050556
-------------+--------------------------------------------------------
       pvvd3 |     10000    .0477859    .0640267   1.23e-06    .658325
       pd663 |     10000    .0369698    .0121552   .0091511   .1173026
      ppvda4 |     10000    .5237542    .1050779   .0148695   .7262714
       pcda4 |     10000    .3167279    .0739144    .107058    .788705
       pvvd4 |     10000    .0641449    .0192341     .01847   .1906632
-------------+--------------------------------------------------------
       pd664 |     10000    .0391993    .0570159   6.45e-07   .6290089
      pvdad2 |     10000   -.3750823    .1483942  -.7346655   .5277294
       cdad2 |     10000    .4241951    .1643741  -.5740547   .8109366
       vvdd2 |     10000   -.0268644    .0339779   -.214408   .0931186
       d66d2 |     10000   -.0121368    .0166855  -.1120509   .0597364
-------------+--------------------------------------------------------
      pvdad3 |     10000    -.066821    .0321768  -.2461148   .0409822
       cdad3 |     10000    .2318832    .1161791  -.6222955    .661868
       vvdd3 |     10000   -.0884245    .0810138  -.3043731   .6055655
       d66d3 |     10000   -.0337777    .0125216  -.1079263   .0089983
      pvdad4 |     10000   -.0699905    .0336297  -.2510901   .0579928
-------------+--------------------------------------------------------
       cdad4 |     10000     .219197    .1116681  -.6164477   .6467797
       vvdd4 |     10000   -.0720656    .0290741  -.2126279   .0183163
       d66d4 |     10000   -.0315482    .0626058  -.1583126    .590632

. 
end of do-file


. exit, clear
